﻿const express = require('express');
const bodyParser = require('body-parser');

const locationRoutes = require('./routes/location');

const app = express();

// app.set('view engine', 'ejs');
// app.set('views','views');

//app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());

app.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
    res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
    next();
})

app.use(locationRoutes);

// app.use((req,
//          res,
//          next) => {
//     res.setHeader('Content-type', 'text/html');
//     next();
// });
//
// app.use((req,
//          res,
//          next)=>{
//     const userName = req.body.username || 'Unknown User';
//     res.render('index',{
//         user: userName
//     });
// });

app.listen(3000);